package com.example.aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * ClassName: AspectDemo
 * Package: IntelliJ IDEA
 * Description:
 *
 * @Author 谷京京
 * @Create 2023/12/2 11:27
 * @Version 1.0
 */
@Aspect
@Slf4j
//@Component
public class AspectDemo {
    @Pointcut("execution(* com.example.aop.controller.*.*(..))")
    public void point() {}
    @Before("point()")
    public void doBefore() {
        log.info("执行AspectDemo Before...");
    }

    @After("point()")
    public void doAfter() {
        log.info("执行AspectDemo After...");
    }

    @AfterReturning("point()")
    public void doAfterReturning() {
        log.info("执行AspectDemo AfterReturning...");
    }

    @AfterThrowing("point()")
    public void doAfterThrowing() {
        log.info("执行AspectDemo AfterThrowing...");
    }

    @Around("point()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("执行AspectDemo Around前...");
        Object result = joinPoint.proceed();
        log.info("执行AspectDemo Around后...");
        return result;
    }
}
